import React from 'react';
import ReactDOM from 'react-dom';

import { createHashHistory } from 'History';

import { Router, Route, useRouterHistory } from 'react-router';

import { syncHistoryWithStore, RouterStore } from 'mobx-react-router';

import { Provider } from 'mobx-react';
import { WeaLocaleProvider } from 'ecCom';
import weaWorkrelate from 'weaWorkrelate';
const routing = new RouterStore();

const allStore = {
  routing,
  ...weaWorkrelate.store,
};

const WorkrelateRoute = weaWorkrelate.Route;

const browserHistory = useRouterHistory(createHashHistory)({
  queryKey: '_key',
  basename: '/',
});

const history = syncHistoryWithStore(browserHistory, allStore.routing);

const getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind(this, 'workrelate');
const Home = props => props.children;

const Root = () => (
  <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@y1rtww`} {...allStore}>
    <Router ecId={`${this && this.props && this.props.ecId || ''}_Router@bvs4i6`} history={history}>
      <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@bsatgc`} name='main' breadcrumbName='入口' path='/main' component={Home} onEnter={getLocaleLabel}>
        { WorkrelateRoute }
      </Route>
    </Router>
  </Provider>
);

ReactDOM.render(<Root ecId={`${this && this.props && this.props.ecId || ''}_Root@28d7op`} />, document.getElementById('container'));
